package org.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.example.model.entity.AccountInfoDO;

import java.math.BigDecimal;

/**
 * @author shenguangyang
 */
@Mapper
public interface AccountInfoMapper extends BaseMapper<AccountInfoDO> {
    @Update("update account_info set balance = balance + #{amount} where no = #{accountNo} and balance > #{amount}")
    int updateAccountBalance(@Param("accountNo") String accountNo, @Param("amount") BigDecimal amount);

    @Select("select count(1) from de_duplication where tx_no = #{txNo}")
    int isExistTx(String txNo);

    @Insert("insert into de_duplication values(#{txNo}, now());")
    int addTx(String txNo);
}
